const myformat = (val) => {
  return parseFloat(val).toString() === "NaN" ? val : parseFloat(val) //.toLocaleString('zh',{style:'decimal'})
}
const dataPercentage = (val1,val2) => {
  let num =  val1 / val2
  if(num >= 1){
    return 100
  }else if(num < 1 && num >= 0.01){
    return Number(num.toFixed(2)) * 100
  }else if(num <= 0){
    return 0
  }
}
/*
日期转换周几
strday:'xxx-xx-xx'格式
*
*/
const getWeek = (strday) => {
  if (!strday) {
    return ''
  }
  let week;
  let day = new Date(strday)
  if(day.getDay() == 0) week = "周日"
  if(day.getDay() == 1) week = "周一"
  if(day.getDay() == 2) week = "周二"
  if(day.getDay() == 3) week = "周三"
  if(day.getDay() == 4) week = "周四"
  if(day.getDay() == 5) week = "周五"
  if(day.getDay() == 6) week = "周六"
  return week;
}
const myfun = {
  myformat,
  dataPercentage,
  getWeek
}

export default myfun
